package GUI;

import java.io.ObjectInputStream;

import core.ChessBoard;

class NetworkBoardReceiver extends Thread {
	ObjectInputStream netIn;
	SocketConnection sockConn;
	ChessGUI gui;
	
	public NetworkBoardReceiver(ObjectInputStream netIn, SocketConnection socket, ChessGUI gui) {
		this.netIn = netIn;
		sockConn = socket;
		this.gui = gui;
	}
	
	public void run(){
		while(true){
			try{
    			ChessBoard temp = (ChessBoard) netIn.readObject();
    			if (temp instanceof core.ChessBoard){
    				gui.setBoard(temp);
    			}
			}catch (Exception e) {
				e.printStackTrace();
			}
			synchronized (this) {
				try{
					wait();
				}catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	}
}
